package top.ezzz;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.http.HttpUtil;
import com.overzealous.remark.Remark;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class App {

    public static void main(String[] args) {
        for (int i = 0; i < 15; i++) {
            try {
                String content = "https://read.qq.com/read/1040681037/" + i;
                String html = HttpUtil.get(content);
                // 解析HTML文档
                Document document = Jsoup.parse(html);
                // 获取段落内容
                Element paragraphs = document.getElementById("article");
                // 将获取到的内容从HTML格式转换为Markdown格式
                Remark remark = new Remark();
                String md = remark.convert(paragraphs.html());

                FileUtil.writeUtf8String(md, FileUtil.file("A:\\bigdata\\article-" + i + ".md"));
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    }
}
